﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Zhj.Community.Domain.Entitys;
using Zhj.Community.Domain.IRepository;
using Zhj.Community.Domain.Test.Dto;
using Zhj.Community.Infrastructure.Mapper;

namespace Zhj.Community.Domain.Test
{
    public class TestService : ITestService
    {
        public ITestStudentRepository TestRepository { set; get; }

        public ITestStudentFirendRepository TestStudentFirendRepository { get; set; }

        public TestService(ITestStudentRepository testRepository, ITestStudentFirendRepository testStudentFirendRepository)
        {
            TestRepository = testRepository;
            TestStudentFirendRepository = testStudentFirendRepository;
        }

        public string TestFunc()
        {
            var info = TestRepository.TestFunc();
            return info;
        }

        public List<StudentList> GetStduentList()
        {
            var list = TestRepository.GetAll();
            var result = MapperMaster.Mapper<List<TestStudent>, List<StudentList>>(list);
            //其他的逻辑
            return result;
        }

        public StudentEdit GetStduentById(long id)
        {
            var edit = TestRepository.Get(id);
            edit.StudentFirend = TestStudentFirendRepository.Get(l => l.StudentId == id);
            var result = MapperMaster.Mapper<TestStudent, StudentEdit>(edit);
            //其他的逻辑
            return result;
        }
    }
}
